package utils

import (
	"fmt"
	"gopkg.in/ini.v1"
)

var (
	AppMode     string
	HttpPort    string
	JwtKey      string
	DB          string
	DbHost      string
	DbName      string
	DbPort      string
	DbUser      string
	DbPassword  string
	AccessKey   string
	SecretKey   string
	Bucket      string
	QiniuServer string
)

func init() {
	file, err := ini.Load("config/config.ini")
	if err != nil {
		fmt.Print("配置文件读取错文件路径", err)
	}
	LoadServer(file)
	LoadData(file)
	LoadQiniu(file)
}

func LoadServer(file *ini.File) {
	AppMode = file.Section("server").Key("AppMode").MustString("debug")
	HttpPort = file.Section("server").Key("HttpPort").MustString(":3000")
	JwtKey = file.Section("server").Key("JwtKey").MustString("weduioplkjhgmnbvcxz;'./.963258147")
}
func LoadData(file *ini.File) {
	DB = file.Section("database").Key("DB").MustString("postgres")
	DbHost = file.Section("database").Key("DbHost").MustString("127.0.0.1")
	DbName = file.Section("database").Key("DbName").MustString("blog")
	DbPort = file.Section("database").Key("DbPort").MustString("5432")
	DbUser = file.Section("database").Key("DbUser").MustString("cow11023")
	DbPassword = file.Section("database").Key("DbPassword").MustString("Cowzyr299025")
}
func LoadQiniu(file *ini.File) {
	AccessKey = file.Section("qiniu").Key("AccessKey").MustString("KHYBTxD9gtf21-9H5_FtT7GdxEOVRVjNLbfaAXy6")
	SecretKey = file.Section("qiniu").Key("SecretKey").MustString("qbHbsDAsRojWgSCkCnamkZqIwS1A2N3qYKnOgErO")
	Bucket = file.Section("qiniu").Key("Bucket").MustString("cow11023")
	QiniuServer = file.Section("qiniu").Key("QiniuServer").MustString("http://qksnuy5sx.hn-bkt.clouddn.com/")
}
